import React from 'react';
//资产包引入
import AssetPackage from '../../../../systemManagement/outsourceInvestMsgMaintain/assetPackage';
class AssetPackages extends React.Component {
  constructor() {
    super();
    this.state = {
      fieldInRow: 4,
    };
  }
  componentDidMount() {
    this.props.onRef && this.props.onRef(this);
    window.addEventListener('resize', this.windowChange);
    this.windowChange();
  }
  // 窗口大小变更触发
  windowChange = () => {
    const screenWidth = document.documentElement.clientWidth;
    if (screenWidth < 1920) {
      this.setState({
        fieldInRow: 3,
      });
    } else {
      this.setState({
        fieldInRow: 4,
      });
    }
  };
  //此时是获取资产包中的内容
  getInfo = () => {
    return this.state.assetPackageRef && this.state.assetPackageRef?.getInfo();
  };

  render() {
    const { pageType } = this.props;
    const { fieldInRow } = this.state;
    return (
      <div style={{ marginBottom: '16px' }}>
        <AssetPackage
          // labelSpan={fieldInRow=='3'? 3: 2}
          type={pageType == 'view' ? 3 : pageType == 'add' ? 1 : 2} //仅在type=3时（查看详情）做置灰处理 1-新增  2-编辑
          initialData={pageType == 'add' ? [] : this.props?.files ? this.props?.files : []}
          onRef={(e) => this.setState({ assetPackageRef: e })}
        />
      </div>
    );
  }
}
export default AssetPackages;
